package com.leetcode.algorithm.y22.m09.w2;

import java.util.Arrays;

/**
 * 2144. 打折购买糖果的最小开销
 * 
 * https://leetcode.cn/problems/minimum-cost-of-buying-candies-with-discount/
 * 
 * @author jie.deng
 *
 */
class Question2144Solution01 {

	public int minimumCost(int[] cost) {
		Arrays.sort(cost);
		int sum = 0;
		int seq = 0;
		for (int i = cost.length - 1; i >= 0; i--) {
			seq++;
			if (seq == 3) {
				seq = 0;
			} else {
				sum += cost[i];
			}
		}
		return sum;
	}

}